using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SunshineFarmWord
{
    // 缓慢跟随脚步 挂在那个脚本上 就会跟随那个脚本
    public class GameObjectFollowNode : MonoBehaviour
    {
        // 需要跟随的物体
        [field: SerializeField]
        private Transform targetTransform;

        void FixedUpdate()
        {
            FollowNode();
        }

        public void FollowNode()
        {
            if (targetTransform == null) return;
            Vector3 followPosition = new Vector3(transform.position.x, transform.position.y, targetTransform.position.z);
            targetTransform.position = Vector3.Lerp(targetTransform.position, followPosition, Time.deltaTime * 2f);
        }
    }
}
